<template>
  <div>
    <header class="am-topbar am-topbar-inverse admin-header" style="z-index: 999">
      <div class="am-topbar-brand">
        <a href="javascript:;" class="tpl-logo1">
          <p class="tpl-logo2">智慧车位云管理端</p>
        </a>
      </div>
      <div class="am-icon-list tpl-header-nav-hover-ico am-fl am-margin-right" @click="hideNav"></div>
      <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>
      <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
          <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen" class="tpl-header-list-link"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
          <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
            <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:;">
              <span class="tpl-header-list-user-nick">{{AdminName}}</span>
            </a>
            <ul class="am-dropdown-content">
              <li><router-link :to="{name:'UpdatePwd'}"><span class="am-icon-cog"></span>修改密码</router-link></li>
              <li><a @click="logout"><span class="am-icon-power-off"></span>退出</a></li>
            </ul>
          </li>
          <li><a @click="logout" class="tpl-header-list-link"><span class="am-icon-sign-out tpl-header-list-ico-out-size"></span></a></li>
        </ul>
      </div>
    </header>
    <router-view></router-view>
    <alert :test="test"></alert>
  </div>
</template>

<script>
  import * as apis from '../apis'

  export default {
    data () {
      return {
        test: '',
        AdminName: ''
      }
    },
    created(){
      
    },
    mounted () {
      // apis.user().then(({data: data}) => {
      //   if (data && data.result_code === 1) this.AdminName = data.result.name
      //     console.log('shenme',data)
      // })
    },
    computed: {
    },
    methods: {
      logout () {
        apis.addLogoutLog().finally(() => {
          window.sessionStorage.removeItem('token')
          this.$router.push({ name: 'Login' })
        })
      },
      hideNav () {
        $('.tpl-left-nav').toggle()
        $('.tpl-content-wrapper').toggleClass('tpl-content-wrapper-hover')
      }
    }
  }
</script>

<style>
  .am-topbar-brand .tpl-logo1 {
    margin-left: 2rem;
  }

  .am-topbar-brand .tpl-logo2 {
    display: inline-block;
    color: #588ebd;
    letter-spacing: 3px;
    text-shadow: 0px 0px 1px #588ebd;
  }
</style>

